Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocomplete jail name function #750

Closed
wants to merge 11 commits into from

Conversation

tschettervictor
Copy link
Contributor

This will allow a user to simple begin typing a jail name. If bastille finds more than one jail starting with what is typed, it will error. If it only find one jail, it will set that jail as the $TARGET

root@webmin:~ # bastille list all
 JID   State  IP Address  Published Ports  Hostname  Release       Path
 teer  Up     10.0.0.3    -                teer      14.0-RELEASE  /usr/local/bastille/jails/teer/root
 test  Up     10.0.0.1    -                test      14.0-RELEASE  /usr/local/bastille/jails/test/root
 tesw  Up     10.0.0.2    -                tesw      14.0-RELEASE  /usr/local/bastille/jails/tesw/root
root@webmin:~ # bastille console te
Multiple jails found for te:
teer test tesw
root@webmin:~ # bastille cmd tes
Multiple jails found for tes:
test tesw
root@webmin:~ # bastille console tee
[teer]:
root@teer:~ #

This will allow a user to simple begin typing a jail name. If bastille finds more than one jail starting with what is typed, it will error. If it only find one jail, it will set that jail as the $TARGET
@tschettervictor
Copy link
Contributor Author

@yaazkal Do you think this is a necessary addition? It is not strictly necessary, but it is a decent enhancement.

A few things i noticed is that some commands are not registered with this function, namely

bootstrap|create|destroy|export|import|list|rdr|restart|setup|start|update|upgrade|verify)
    # Nothing "extra" to do for these commands. -- cwells
    ;;

This function would have to be called in their own CMD file.

@tschettervictor
Copy link
Contributor Author

I've now added the function to all necessary CMD files.

@tschettervictor tschettervictor changed the title Add autocomplete function to main bastille executable Add autocomplete jail name function Nov 25, 2024
@michael-o
Copy link
Contributor

Why not add to bash completions?

@tschettervictor
Copy link
Contributor Author

tschettervictor commented Nov 29, 2024

Go on…
The idea is to grep the jails directory here.
Also, I want to be able to type “bastille console next” to access a jail called nextcloud.

I suppose “tab-ing” would work also though.

@tschettervictor
Copy link
Contributor Author

Using tab will not work. If you have any type of directory in the root (or wherever you run bastille command from) it will auto complete directories and files in PWD.

I think it better to use the function as-is.

@pepe82sh
Copy link

pepe82sh commented Dec 2, 2024

@tschettervictor funny this is very recent. I couldn't find any completion scripts for zsh (or bash) to have proper Bastille completion support in the shell. That'd include suggestions for subcommands, options and jails. Is this by any chance planned, or if it isn't, would adding completions for zsh or bash be accepted as a PR?

@tschettervictor
Copy link
Contributor Author

@yaazkal Thoughts?

@tschettervictor
Copy link
Contributor Author

Closed in favor of #758 which improves handling of this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants